<template>
  <PermissionErrorDialog 
    v-model="visible" 
    :error="currentError"
    @close="handleClose"
  />
</template>

<script setup>
import { ref, onMounted } from 'vue'
import PermissionErrorDialog from './PermissionErrorDialog.vue'
import permissionErrorHandler from '../utils/permissionErrorHandler'

// 响应式数据
const visible = ref(false)
const currentError = ref(null)

// 方法
const showError = (error) => {
  currentError.value = error
  visible.value = true
}

const handleClose = () => {
  visible.value = false
  currentError.value = null
}

// 生命周期
onMounted(() => {
  // 注册到权限错误处理器
  permissionErrorHandler.setErrorDialogRef({
    showError
  })
})

// 暴露方法给父组件
defineExpose({
  showError
})
</script>

<style scoped>
/* 样式在子组件中定义 */
</style> 